package MyInput;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class ManyInput {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int T = scan.nextInt();
        scan.nextLine(); //换行

        while (T-- != 0){
            int number = scan.nextInt();
            scan.nextLine(); //换行

            String[] ss = new String[number];
            for(int i=0; i<number; i++){
                String aa = scan.nextLine();
                ss[i] = aa;
            }
            Arrays.sort(ss);
            System.out.println();
            for(String sss: ss){
                System.out.println(sss);
            }

        }


    }
}
